<style>
.ci_1 {
    width:100px !important;
}

.ci_3 {
    width:420px !important;
}

.ci_5 {
    width: 100px !important;
}

</style>

<<if ($lang == "eng" || $lang == "")>>
<a class="lang" href="index.php?choice=profile&lang=hun<<if ($extrabusinesslead)>>&_type=businesslead<</if>>" style="position:relative; top:-25px;left:800px;">magyarul</a>
<<else>>
<a class="lang" href="index.php?choice=profile&lang=eng<<if ($extrabusinesslead)>>&_type=businesslead<</if>>" style="position:relative; top:-25px;left:800px;">english</a>
<</if>>

<form name="profile" method="post" action="index.php?mode=service&page=companyprofile&service=save">
    <input type="hidden" name="is_habroad" value="<<$hungarian_abroad>>">
<<if (!$extrabusinesslead)>>
<fieldset>
    <legend><<$lng.contactinfo>></legend>
    <table width="100%" class="formtable">
        <tr>
            <td colspan=2><<inputtext required='1' value="`$companyprofile.companyname`" title="<<$lng.companyname>>" name="companyname">></td>
<<if ($user.registertype == "1" || $user.registertype == "5")>>
            <td><input type="checkbox" class="checkbox" onclick="toggleUploadButton(this)" name="logo"><label for="logo"><<$lng.uploadcompanylogo>></label></td>
            <td><<$lng.freeofcharge>></td>
            <td><input class="logo_preview_hidden" type="hidden" name="logo_id" value="<<$companyprofile.logo_id>>"><img logoid="<<$companyprofile.logo_id>>" height=30 src="" id="logo_preview"></td>
            <td width="20%"><<jqbutton id="logouploader" style="display:none;" title="<<$lng.addlogo>>" onclick="uploadCompanyLogo(); return false;">></td>
<</if>>
        </tr>
</table>
    <table class="formtable">
        <<if ($user.registertype == "5")>>
        <tr>
            <td colspan=6><<inputtext value="`$companyprofile.country`" title="<<$lng.country>>" name="country" style="width:370px;">></td>
        </tr>
        <</if>>
        <tr>
            <td colspan=6>
            <<combinedinput values="<<$companyprofile.zipcode>>,<<$companyprofile.city>>,<<$companyprofile.street>>,<<$companyprofile.sttype>>,<<$companyprofile.houseno>>" required='1' fields="zipcode,city,street,sttype,houseno" titles="<<$lng.zipcode>>,<<$lng.city>>,<<$lng.street>>,<<$lng.sttype>>,<<$lng.houseno>>">>
            </td>
        </tr>
        <tr>
            <td colspan=6>
            <<inputtext value="<<$companyprofile.taxno>>" name="taxno" title="<<$lng.taxno>>">>
            </td>
        </tr>
        <tr>
            <td><<inputtext value="`$companyprofile.hpenglish`"  title="<<$lng.englishws>>" name="hpenglish" class="width200">></td>
            <td><<inputtext value="`$companyprofile.hphungarian`" title="<<$lng.hungarianws>>" name="hphungarian" class="width200">></td>
            <td colspan=4>&nbsp;</td>
        </tr>
<<if ($user.registertype == "1")>>
        <tr>
            <td><<inputtext title="<<$lng.exportcp>>" required='1' value="`$companyprofile.contactperson1`" name="contactperson1" class="width200">></td>
            <td><<inputtext title="<<$lng.importcp>>" name="contactperson2" class="width200" value="`$companyprofile.contactperson2`">></td>
            <td colspan=4>&nbsp;</td>
        </tr>
<<else>>
        <tr>
            <td colspan=2><<inputtext title="<<$lng.contactperson>>" required='1' value="`$companyprofile.contactperson1`" name="contactperson1" style="width:370px;">></td>
            <td colspan=4>&nbsp;</td>
        </tr>
<</if>>
        <tr>
<<if ($user.registertype == "1")>>
            <td><<inputtext value="`$companyprofile.jobtitle1`" title="<<$lng.jobtitle>>" name="jobtitle1" class="width200">></td>
            <td><<inputtext value="`$companyprofile.jobtitle2`" title="" name="jobtitle2" class="width200">></td>
            <td colspan=4>&nbsp;</td>
<<else>>
            <td colspan=2><<inputtext value="`$companyprofile.jobtitle1`" title="<<$lng.jobtitle>>" name="jobtitle1" style="width:370px;">></td>
            <td colspan=4>&nbsp;</td>
<</if>>
        </tr>
        <tr>
<<if ($user.registertype == "1")>>
            <td><<inputtext value="`$companyprofile.email1`" required='1' title="<<$lng.email>>" name="email1" class="width200">></td>
            <td><<inputtext value="`$companyprofile.email2`" title="" name="email2" class="width200">></td>
            <td colspan=4>&nbsp;</td>
<<else>>
            <td colspan=2><<inputtext value="`$companyprofile.email1`" required='1' title="<<$lng.email>>" name="email1" style="width:370px;">></td>
            <td colspan=4>&nbsp;</td>
<</if>>
        </tr>
        <tr>
<<if ($user.registertype == "1")>>
            <td><<inputtext value="`$companyprofile.phone1`" title="<<$lng.phone>>" name="phone1" class="width200">></td>
            <td><<inputtext value="`$companyprofile.phone2`" title="" name="phone2" class="width200">></td>
            <td colspan=4>&nbsp;</td>
<<else>>
            <td colspan=2><<inputtext value="`$companyprofile.phone1`" title="<<$lng.phone>>" name="phone1" style="width:370px;">></td>
            <td colspan=4>&nbsp;</td>
<</if>>
        </tr>
        <tr>
<<if ($user.registertype == "1")>>
            <td><<inputtext value="`$companyprofile.fax1`" title="<<$lng.fax>>" name="fax1" class="width200">></td>
            <td><<inputtext value="`$companyprofile.fax2`" title="" name="fax2" class="width200">></td>
            <td colspan=4>&nbsp;</td>
<<else>>
            <td colspan=2><<inputtext value="`$companyprofile.fax1`" title="<<$lng.fax>>" name="fax1" style="width:370px;">></td>
            <td colspan=4>&nbsp;</td>
<</if>>
        </tr>

<<if ($hungarian_abroad == 1)>>
        <tr>
            <td colspan=6>Activity description<br>
            <textarea name="activity" cols=160 rows=15><<$companyprofile.activity>></textarea></td>
        </tr>
    </table>
<table>
<tr><td><input class="checkbox" type="checkbox" value="on" name="emailupdates" <<if ($userdata.wantnewsletter)>>checked="checked"<</if>>></td><td><<$lng.emailupdates>></td></tr>
</table>
    <<jqbutton type="submit" title="<<$lng.savecontact>>" style="width:150px;" onclick="submitContact('profile', 'Saving profile, please wait...', this); submitted = true; return false;">>
    <<jqbutton type="submit" title="<<$lng.changepw>>" style="width:150px;" onclick="gotoChangePw(); return false;">>
</fieldset>
<<else>>
    </table>
<table>
<tr><td><input name="emailupdates" class="checkbox" type="checkbox" value="on" <<if ($userdata.wantnewsletter)>>checked="checked"<</if>>></td><td><<$lng.emailupdates>></td></tr>
</table>
    <<jqbutton type="submit" title="<<$lng.savecontact>>" style="width:150px;" onclick="submitContact('profile', 'Saving profile, please wait...', this); submitted = true; return false;">>
    <<jqbutton type="submit" title="<<$lng.changepw>>" style="width:150px;" onclick="gotoChangePw(); return false;">>

</fieldset>
<</if>>
<</if>>
<fieldset>
<<if ($user.registertype == "1" && !$displayBusinessLeadProfile)>>
<<include file="pages/companyprofile/profile_exportimport.tpl">>
<</if>>
<<if ($user.registertype == "2")>>
<<include file="pages/companyprofile/profile_services.tpl">>
<</if>>
<<if ($user.registertype == "3" || $user.registertype == "4" || $displayBusinessLeadProfile)>>
<<include file="pages/companyprofile/profile_businesslead.tpl">>
<</if>>
<<if ($user.registertype == "5" && !$displayBusinessLeadProfile)>>
<<include file="pages/companyprofile/profile_habroad.tpl">>
<</if>>


</form>

<script>
var amount = 0;
var sponsorationChanged = false;

function writeAmount(am) {
    jQuery("div#amount").html(formatNumbers(am));
    jQuery("div#amount_eur").html(formatNumbers(am * huf_eur));
    jQuery("div#amount_usd").html(formatNumbers(am * huf_usd));
}

var submitted = false;

var emailUpdateCounter = 0;

jQuery("form[name='profile']").multipageform({
    onselect : function(currentTabIndex, newTabIndex) {
        if (currentTabIndex > 0) { return true; }
        if (!multiform_changed(jQuery("form[name='profile']"), currentTabIndex)) {
            if (multiform_validateTab(jQuery("form[name='profile']"), currentTabIndex)) {
                if (jQuery("input[type='checkbox'][name='emailupdates']").attr("checked")) {
                    return true;
                } else {
                    if (emailUpdateCounter == 0) {
                        emailUpdateCounter++;
                        displayFormErrors({
                            emailupdates : {code : "0", msg : "<<$lng.areyousure>><br><ul><li><<$lng.lst_emailupdates>></li></ul>"}
                        });
                        return false;
                    }
                    hideFormErrors();
                    return true;
                }
            }
            return false;
        }
        return submitted;
    }
});

function submitContact(formName, waitMsg, buttonItem) {
    multiform_saveCurrentTab(jQuery("form[name='profile']"), 0, waitMsg, buttonItem, {}, function() {
        multiform_switch(jQuery("form[name='profile']"), 1);
    });
}

function toggleUploadButton(item) {
    if (item.checked) {
        jQuery("#logouploader").show("fade", {}, 300);
    } else {
        jQuery("#logouploader").hide("fade", {}, 300);
    }
}

var huf_eur = <<$huf_eur>>;
var huf_usd = <<$huf_usd>>;

jQuery("input.month").change(function() {
    recalculateAmount();
/*
    var prevValue = parseInt(jQuery(this).attr("prev"), 10);
    var currentValue = parseInt(jQuery(this).val(), 10);
    var multiplier = parseInt(jQuery(this).attr("base"), 10);
    amount = amount-prevValue*multiplier + currentValue*multiplier;
    jQuery(this).attr("prev", currentValue);
*/
});

function checkboxClicked(item, multiplier) {
    recalculateAmount();
/*
    if (item.checked) {
        checkboxEnabled(jQuery(item), multiplier);
    } else {
        checkboxDisabled(jQuery(item), multiplier);
    }
*/
}

function checkboxEnabled(cb, multiplier) {
    var currentValue = parseInt(jQuery(cb).parents("tr").first().find("input.month").first().val(), 10);
    amount = amount + currentValue*multiplier;
    writeAmount(amount);
}

function checkboxDisabled(cb, multiplier) {
    var currentValue = parseInt(jQuery(cb).parents("tr").first().find("input.month").first().val(), 10);
    amount = amount - currentValue*multiplier;
    writeAmount(amount);
}

writeAmount(0);

jQuery("input[type='checkbox'].sponsor").click(function() {
    if (this.checked) { sponsorationChanged = true; } else { sponsorationChanged = false; }
});

function gotoChangePw() {
    redirect("personalprofile", "", {}, false);
}

var photoCount = 0;
</script>

<<include file="layout/accessories.tpl">>
